﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using WebServer.DBUtility;
using WebServer.Models;

namespace WebServer.DBAccess
{
    public class NewsDA
    {

        #region 分类逻辑
        /// <summary>
        /// 获取所有的子分类 
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public List<NewsCate> ManCate(bool IsDel)
        {
            List<NewsCate> request = new List<NewsCate>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_Ctae_Q", new object[] { IsDel }))
                {

                    while (reader.Read())
                    {
                        NewsCate entity = new NewsCate();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        if (reader[2] != DBNull.Value)
                            entity.Parent = reader[2].ToInt32();
                        else
                            entity.Parent = 0;             
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }

        /// <summary>
        /// 获取分类
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public List<NewsCate> Cate(int ID, bool IsDel)
        {
            List<NewsCate> request = new List<NewsCate>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_Ctae", new object[] { ID, IsDel }))
                {

                    while (reader.Read())
                    {
                        NewsCate entity = new NewsCate();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        if (reader[2] != DBNull.Value)
                            entity.Parent = reader[2].ToInt32();
                        else
                            entity.Parent = 0;
                        entity.PaName = reader[3].ToString();
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }

        /// <summary>
        /// 获取分类
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public NewsCate CateByID(int ID)
        {
            NewsCate request = new NewsCate();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_Ctae_ByID", new object[] { ID }))
                {

                    while (reader.Read())
                    {
                        if (reader[0] != DBNull.Value)
                            request.ID = reader[0].ToInt32();
                        else
                            request.ID = 0;
                        request.Name = reader[1].ToString();
                        if (reader[2] != DBNull.Value)
                            request.Parent = reader[2].ToInt32();
                        else
                            request.Parent = 0;
                        if (reader[3] != DBNull.Value)
                            request.IsDel = reader[3].ToBoolean();
                        else
                            request.IsDel = false;
                        if (reader[4] != DBNull.Value)
                            request.CreateTime = reader[4].ToDateTime();
                        else
                            request.CreateTime = DateTime.Now;
                        if (reader[5] != DBNull.Value)
                            request.Updatetime = reader[5].ToDateTime();
                        else
                            request.Updatetime = DateTime.Now;
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }

        /// <summary>
        /// 获取分类
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public bool CateCreate(string Name, int ParentID)
        {
            bool request = false;
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_Ctae_Create", new object[] { Name, ParentID }))
                {

                    while (reader.Read())
                    {
                        request = reader[0] != DBNull.Value ? (reader[0].ToInt32() > 0 ? true : false) : false;
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }

        /// <summary>
        /// 更新分类
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public bool CateSet(int ID, string Name, int Parent, bool IsDel)
        {
            bool request = false;
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_Ctae_Set", new object[] { ID, Name, Parent, IsDel }))
                {

                    while (reader.Read())
                    {
                        request = reader[0] != DBNull.Value ? (reader[0].ToInt32() > 0 ? true : false) : false;
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }

        /// <summary>
        /// 新闻动作
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="Fild"></param>
        /// <param name="Fn"></param>
        /// <returns></returns>
        public static int CateAction(int ID, string Fild, bool Fn)
        {
            try
            {
                object[] whereInfo = new object[] { ID, Fild, Fn };
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Cate_Action]", whereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        /// <summary>
        /// 获取判断是否有子节点的分类
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public static List<NewsCate> CateList(int ID, bool IsDel)
        {
            List<NewsCate> request = new List<NewsCate>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Cate_Q]", new object[] { ID, IsDel }))
                {

                    while (reader.Read())
                    {
                        NewsCate entity = new NewsCate();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        if (reader[2] != DBNull.Value)
                            entity.Parent = reader[2].ToInt32();
                        else
                            entity.Parent = 0;
                        if (reader[3] != DBNull.Value)
                            entity.childID = reader[3].ToInt32();
                        else
                            entity.childID = 0;
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }
        #endregion


        #region 资讯处理
        /// <summary>
        /// 获取存在交易所
        /// </summary>
        /// <returns></returns>
        public List<NewsBourseGroupEntity> BourseGroup()
        {
            List<NewsBourseGroupEntity> request = new List<NewsBourseGroupEntity>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_Bourse", new object[] { }))
                {

                    while (reader.Read())
                    {
                        NewsBourseGroupEntity entity = new NewsBourseGroupEntity();
                        entity.Name = reader[0].ToString();
                        entity.Shortened = reader[1].ToString();
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }


        /// <summary>
        /// 获取存在交易所【有centerID】
        /// </summary>
        /// <returns></returns>
        public List<NewsBourseGroupEntity> PBourseGroup()
        {
            List<NewsBourseGroupEntity> request = new List<NewsBourseGroupEntity>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bourse_P]", new object[] { }))
                {

                    while (reader.Read())
                    {
                        NewsBourseGroupEntity entity = new NewsBourseGroupEntity();
                        entity.Shortened = reader[0].ToString();
                        entity.Name = reader[1].ToString();
                        if (reader[2] != DBNull.Value)
                            entity.CenterID = reader[2].ToInt32();
                        else
                            entity.CenterID = 0;
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }



        /// <summary>
        /// 获取存在交易所
        /// </summary>
        /// <returns></returns>
        public List<NewsCate> CateGroup(int Parent, string Name)
        {
            List<NewsCate> request = new List<NewsCate>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_CateGroup", new object[] { Parent,Name }))
                {

                    while (reader.Read())
                    {
                        NewsCate entity = new NewsCate();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        if (reader[2] != DBNull.Value)
                            entity.Parent = reader[2].ToInt32();
                        else
                            entity.Parent = 0;
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }

        /// <summary>
        /// 获取新闻详情
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public News NewsByID(int ID)
        {
            News request = new News();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_News_ByID", new object[] { ID }))
                {

                    while (reader.Read())
                    {
                        if (reader[0] != DBNull.Value)
                            request.ID = reader[0].ToInt32();
                        else
                            request.ID = 0;
                        if (reader[1] != DBNull.Value)
                            request.CateID = reader[1].ToInt32();
                        else
                            request.CateID = 0;
                        request.Title = reader[2].ToString();
                        request.SmallTitle = reader[3].ToString();
                        request.Text = reader[4].ToString();
                        request.Url = reader[5].ToString();
                        if (reader[6] != DBNull.Value)
                            request.Hits = reader[6].ToInt32();
                        else
                            request.Hits = 0;
                        request.Shortened = reader[7].ToString();
                        request.Name = reader[8].ToString();
                        if (reader[9] != DBNull.Value)
                            request.CreateTime = reader[9].ToDateTime();
                        else
                            request.CreateTime = DateTime.Now;
                        if (reader[10] != DBNull.Value)
                            request.IsEdit = reader[10].ToBoolean();
                        else
                            request.IsEdit = false;
                        if (reader[11] != DBNull.Value)
                            request.IsDel = reader[11].ToBoolean();
                        else
                            request.IsDel = false;
                        if (reader[12] != DBNull.Value)
                            request.UpdateTime = reader[12].ToDateTime();
                        else
                            request.UpdateTime = DateTime.Now;
                        if (reader[13] != DBNull.Value)
                            request.Commend = reader[13].ToBoolean();
                        else
                            request.Commend = false;
                        request.Img = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            request.Stick = reader[15].ToBoolean();
                        else
                            request.Stick = false;
                        request.Style = reader[16].ToString();
                        if (reader[17] != DBNull.Value)
                            request.IsHeadline = reader[17].ToBoolean();
                        else
                            request.IsHeadline = false;
                        request.CateName = reader[18].ToString();
                        if (reader[19] != DBNull.Value)
                            request.Retotal= reader[19].ToInt32();
                        else
                           request.Retotal = 0;
                        if (reader[20] != DBNull.Value)
                            request.UserID = reader[20].ToInt32();
                        else
                            request.UserID = 0;
                        request.UserName = reader[21].ToString();
                        if (reader[22] != DBNull.Value)
                            request.UserCateID = reader[22].ToInt32();
                        else
                            request.UserCateID = 0;
                        if (reader[23] != DBNull.Value)
                            request.CenterID = reader[23].ToInt32();
                        else
                            request.CenterID = 0;
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }

        /// <summary>
        /// 获取新闻详情
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="Sort">0:点击量;1:ID;;2创建时间;3:更新时间 ;4:评论</param>
        /// <returns></returns>
        public List<News> NewsBySort(int CateID, bool IsHeadle, int Size, int Sort, bool Desc)
        {
            List<News> request = new List<News>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_News_Sort", new object[] { CateID, IsHeadle, Size, Sort, Desc }))
                {

                    while (reader.Read())
                    {
                        News entity = new News();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.CateID = reader[1].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Title = reader[2].ToString();
                        entity.SmallTitle = reader[3].ToString();
                        
                        if (reader[4] != DBNull.Value)
                            entity.Hits = reader[4].ToInt32();
                        else
                            entity.Hits = 0;
                        entity.Shortened = reader[5].ToString();
                        entity.Name = reader[6].ToString();
                        if (reader[7] != DBNull.Value)
                            entity.CreateTime = reader[7].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;

                        entity.Img = reader[8].ToString();
                        entity.TWord = reader[10].ToString();
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }

       /// <summary>
        /// 后台获取新闻
       /// </summary>
       /// <param name="CateID"></param>
       /// <param name="PageSize"></param>
       /// <param name="PageIndex"></param>
       /// <param name="Title"></param>
       /// <param name="BourseName"></param>
       /// <param name="IsStick"></param>
       /// <param name="IsHeadline"></param>
       /// <param name="HasImg"></param>
       /// <param name="Order">默认为创建时间，1-标题，2-点击率3-交易所，4-回复数</param>
       /// <param name="Desc"></param>
       /// <param name="IsDel"></param>
        /// <returns></returns>
        public List<News> MNewsList(int CateID, int PageSize, int PageIndex, string Title, string BourseName, int IsStick, int IsHeadline, bool HasImg, int Order, bool Desc, int IsDel)
        {
            List<News> request = new List<News>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { CateID, PageSize, (PageIndex - 1) * PageSize, Title, BourseName, IsStick, IsHeadline, HasImg, Order, Desc, IsDel };
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_News_MQ]", obj))
                {

                    while (reader.Read())
                    {
                        News entity = new News();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.CateID = reader[1].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Title = reader[2].ToString();
                        entity.SmallTitle = reader[3].ToString();

                        if (reader[4] != DBNull.Value)
                            entity.Hits = reader[4].ToInt32();
                        else
                            entity.Hits = 0;
                        entity.Shortened = reader[5].ToString();
                        entity.Name = reader[6].ToString();
                        if (reader[7] != DBNull.Value)
                            entity.CreateTime = reader[7].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;

                        entity.Img = reader[8].ToString();
                        if (reader[9] != DBNull.Value)
                            entity.Retotal = reader[9].ToInt32();
                        else
                            entity.Retotal = 0;
                        if (reader[10] != DBNull.Value)
                            entity.Commend = reader[10].ToBoolean();
                        else
                            entity.Commend = false;
                        if (reader[11] != DBNull.Value)
                            entity.Stick = reader[11].ToBoolean();
                        else
                            entity.Stick = false;
                        if (reader[12] != DBNull.Value)
                            entity.IsHeadline = reader[12].ToBoolean();
                        else
                            entity.IsHeadline = false;
                        if (reader[13] != DBNull.Value)
                            entity.IsPush = reader[13].ToBoolean();
                        else
                            entity.IsPush = false;
                        entity.CateName = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            entity.IsDel = reader[15].ToBoolean();
                        else
                            entity.IsDel = false;
                        entity.Style = reader[16].ToString();
                        entity.EditTitle = reader[17].ToString();
                        entity.Description = reader[18].ToString();
                        entity.TWord = reader[19].ToString();
                        entity.KeysWord = reader[20].ToString();
                        entity.Label = reader[21].ToString();
                        entity.Origin = reader[22].ToString();
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }

        /// <summary>
        /// 后台获取新闻总数
        /// </summary>
        /// <param name="CateID"></param>     
        /// <param name="Title"></param>
        /// <param name="BourseName"></param>
        /// <param name="IsStick">0-不置顶，1-置顶，-1代表全部</param>
        /// <param name="IsHeadline">0-不是头条，1-是头条，-1代表全部</param>
        /// <param name="HasImg"></param>    
        /// <param name="IsDel">0-未删除，1-已删除，-1代表全部</param>
        /// <returns></returns>
        public int MNewsCount(int CateID, string Title, string BourseName, int IsStick, int IsHeadline, bool HasImg, int IsDel)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] where = new object[] { CateID, Title, BourseName, IsStick, IsHeadline, HasImg, IsDel };
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_News_MQC]", where);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return 0;
            }
            catch (Exception ex)
            {
                return 0;
            }
        }


        /// <summary>
        /// 根据CenterID获取新闻
        /// </summary>
        /// <param name="CateID"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="Title"></param>
        /// <param name="CenterID"></param>
        /// <param name="IsStick"></param>
        /// <param name="IsHeadline"></param>
        /// <param name="HasImg"></param>
        /// <param name="Order">默认为创建时间，1-标题，2-点击率3-交易所，4-回复数</param>
        /// <param name="Desc"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public List<News> NewsListByCenterID(int CateID, int PageSize, int PageIndex, string Title, int CenterID, int IsStick, int IsHeadline, bool HasImg, int Order, bool Desc, int IsDel)
        {
            List<News> request = new List<News>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { CateID, PageSize, (PageIndex - 1) * PageSize, Title, CenterID, IsStick, IsHeadline, HasImg, Order, Desc, IsDel };
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_News_QByCenterID]", obj))
                {

                    while (reader.Read())
                    {
                        News entity = new News();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.CateID = reader[1].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Title = reader[2].ToString();
                        entity.SmallTitle = reader[3].ToString();

                        if (reader[4] != DBNull.Value)
                            entity.Hits = reader[4].ToInt32();
                        else
                            entity.Hits = 0;
                        entity.Shortened = reader[5].ToString();
                        entity.Name = reader[6].ToString();
                        if (reader[7] != DBNull.Value)
                            entity.CreateTime = reader[7].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;

                        entity.Img = reader[8].ToString();
                        if (reader[9] != DBNull.Value)
                            entity.Retotal = reader[9].ToInt32();
                        else
                            entity.Retotal = 0;
                        if (reader[10] != DBNull.Value)
                            entity.Commend = reader[10].ToBoolean();
                        else
                            entity.Commend = false;
                        if (reader[11] != DBNull.Value)
                            entity.Stick = reader[11].ToBoolean();
                        else
                            entity.Stick = false;
                        if (reader[12] != DBNull.Value)
                            entity.IsHeadline = reader[12].ToBoolean();
                        else
                            entity.IsHeadline = false;
                        if (reader[13] != DBNull.Value)
                            entity.IsPush = reader[13].ToBoolean();
                        else
                            entity.IsPush = false;
                        entity.CateName = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            entity.IsDel = reader[15].ToBoolean();
                        else
                            entity.IsDel = false;
                        entity.Style = reader[16].ToString();
                        entity.EditTitle = reader[17].ToString();
                        entity.Description = reader[18].ToString();
                        entity.TWord = reader[19].ToString();
                        entity.KeysWord = reader[20].ToString();
                        entity.Label = reader[21].ToString();
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }


        /// <summary>
        /// 获取新闻详情
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public List<News> NewsList(int CateID, int Page, int PageSize, string BourseName,bool IsStick, bool IsHeadline, bool HasImg,bool IsDel)
        {
            List<News> request = new List<News>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_News_Q", new object[] { CateID, Page, PageSize, BourseName, IsStick, IsHeadline, HasImg, IsDel }))
                {

                    while (reader.Read())
                    {
                        News entity = new News();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.CateID = reader[1].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Title = reader[2].ToString();
                        entity.SmallTitle = reader[3].ToString();

                        if (reader[4] != DBNull.Value)
                            entity.Hits = reader[4].ToInt32();
                        else
                            entity.Hits = 0;
                        entity.Shortened = reader[5].ToString();
                        entity.Name = reader[6].ToString();
                        if (reader[7] != DBNull.Value)
                            entity.CreateTime = reader[7].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;

                        entity.Img = reader[8].ToString();
                        if (reader[9] != DBNull.Value)
                          entity.Retotal = reader[9].ToInt32();
                        else
                           entity.Retotal = 0;
                        if (reader[10] != DBNull.Value)
                            entity.Commend = reader[10].ToBoolean();
                        else
                            entity.Commend = false;
                        if (reader[11] != DBNull.Value)
                            entity.Stick = reader[11].ToBoolean();
                        else
                            entity.Stick = false;
                        if (reader[12] != DBNull.Value)
                            entity.IsHeadline = reader[12].ToBoolean();
                        else
                            entity.IsHeadline = false;
                        if (reader[13] != DBNull.Value)
                            entity.IsPush = reader[13].ToBoolean();
                        else
                            entity.IsPush = false;
                        entity.CateName = reader[14].ToString();
                        entity.Style = reader[15].ToString();
                        entity.EditTitle = reader[16].ToString();
                        entity.Description = reader[17].ToString();
                        entity.TWord = reader[18].ToString();
                        entity.KeysWord = reader[19].ToString();
                        entity.Label = reader[20].ToString();
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }


        /// <summary>
        /// 获取没有解读的新闻
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public List<News> NoReadingNewsList(int CateID, int Page, int PageSize, string BourseName, bool IsStick, bool IsHeadline, bool HasImg, bool IsDel)
        {
            List<News> request = new List<News>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_News_NoReadingQ", new object[] { CateID, Page, PageSize, BourseName, IsStick, IsHeadline, HasImg, IsDel }))
                {

                    while (reader.Read())
                    {
                        News entity = new News();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.CateID = reader[1].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Title = reader[2].ToString();
                        entity.SmallTitle = reader[3].ToString();

                        if (reader[4] != DBNull.Value)
                            entity.Hits = reader[4].ToInt32();
                        else
                            entity.Hits = 0;
                        entity.Shortened = reader[5].ToString();
                        entity.Name = reader[6].ToString();
                        if (reader[7] != DBNull.Value)
                            entity.CreateTime = reader[7].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;

                        entity.Img = reader[8].ToString();
                        if (reader[9] != DBNull.Value)
                            entity.Retotal = reader[9].ToInt32();
                        else
                            entity.Retotal = 0;
                        if (reader[10] != DBNull.Value)
                            entity.Commend = reader[10].ToBoolean();
                        else
                            entity.Commend = false;
                        if (reader[11] != DBNull.Value)
                            entity.Stick = reader[11].ToBoolean();
                        else
                            entity.Stick = false;
                        if (reader[12] != DBNull.Value)
                            entity.IsHeadline = reader[12].ToBoolean();
                        else
                            entity.IsHeadline = false;
                        if (reader[13] != DBNull.Value)
                            entity.IsPush = reader[13].ToBoolean();
                        else
                            entity.IsPush = false;
                        entity.CateName = reader[14].ToString();
                        entity.Style = reader[15].ToString();
                        entity.EditTitle = reader[16].ToString();
                        entity.Description = reader[17].ToString();
                        entity.TWord = reader[18].ToString();
                        entity.KeysWord = reader[19].ToString();
                        entity.Label = reader[20].ToString();
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }

        /// <summary>
        /// 新闻动作
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public bool NewsAction(int ID,string Filed,bool Fn)
        {
            bool request = false;
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_News_Action", new object[] { ID, Filed, Fn }))
                {

                    while (reader.Read())
                    {
                        request = reader[0] != DBNull.Value ? (reader[0].ToInt32() > 0 ? true : false) : false;
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }



        /// <summary>
        /// 新增以及更新新闻
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public bool NewsSet(News N)
        {
            bool request = false;
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_News_Set", new object[] { N.ID, N.CateID, N.Name, N.Shortened, N.SmallTitle, N.Text, N.Title, N.Style, N.CreateTime, N.Img, N.Hits }))
                {

                    while (reader.Read())
                    {
                        request = reader[0] != DBNull.Value ? (reader[0].ToInt32() > 0 ? true : false) : false;
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }



        /// <summary>
        /// 新增以及更新新闻
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public int NewsInfoSet(News N)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("sp_N_News_SetInfo", new object[] { N.ID, N.CateID, N.Name, N.Shortened, N.SmallTitle, N.Text, N.Title, N.Style, N.CreateTime, N.Img, N.Hits, N.EditTitle, N.Description, N.TWord, N.KeysWord, N.Origin});
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return 0;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }


        /// <summary>
        /// 获取新闻详情
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public News NewsInfoByID(int ID)
        {
            News request = new News();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_NewsInfo_ByID", new object[] { ID }))
                {

                    while (reader.Read())
                    {
                        if (reader[0] != DBNull.Value)
                            request.ID = reader[0].ToInt32();
                        else
                            request.ID = 0;
                        if (reader[1] != DBNull.Value)
                            request.CateID = reader[1].ToInt32();
                        else
                            request.CateID = 0;
                        request.Title = reader[2].ToString();
                        request.SmallTitle = reader[3].ToString();
                        request.Text = reader[4].ToString();
                        request.Url = reader[5].ToString();
                        if (reader[6] != DBNull.Value)
                            request.Hits = reader[6].ToInt32();
                        else
                            request.Hits = 0;
                        request.Shortened = reader[7].ToString();
                        request.Name = reader[8].ToString();
                        if (reader[9] != DBNull.Value)
                            request.CreateTime = reader[9].ToDateTime();
                        else
                            request.CreateTime = DateTime.Now;
                        if (reader[10] != DBNull.Value)
                            request.IsEdit = reader[10].ToBoolean();
                        else
                            request.IsEdit = false;
                        if (reader[11] != DBNull.Value)
                            request.IsDel = reader[11].ToBoolean();
                        else
                            request.IsDel = false;
                        if (reader[12] != DBNull.Value)
                            request.UpdateTime = reader[12].ToDateTime();
                        else
                            request.UpdateTime = DateTime.Now;
                        if (reader[13] != DBNull.Value)
                            request.Commend = reader[13].ToBoolean();
                        else
                            request.Commend = false;
                        request.Img = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            request.Stick = reader[15].ToBoolean();
                        else
                            request.Stick = false;
                        request.Style = reader[16].ToString();
                        if (reader[17] != DBNull.Value)
                            request.IsHeadline = reader[17].ToBoolean();
                        else
                            request.IsHeadline = false;
                        request.CateName = reader[18].ToString();
                        if (reader[19] != DBNull.Value)
                            request.Retotal = reader[19].ToInt32();
                        else
                            request.Retotal = 0;
                        if (reader[20] != DBNull.Value)
                            request.UserID = reader[20].ToInt32();
                        else
                            request.UserID = 0;
                        request.UserName = reader[21].ToString();
                        if (reader[22] != DBNull.Value)
                            request.UserCateID = reader[22].ToInt32();
                        else
                            request.UserCateID = 0;
                        if (reader[23] != DBNull.Value)
                            request.CenterID = reader[23].ToInt32();
                        else
                            request.CenterID = 0;
                        request.EditTitle = reader[24].ToString();
                        request.Description = reader[25].ToString();
                        request.TWord = reader[26].ToString();
                        request.KeysWord = reader[27].ToString();
                        request.Label = reader[28].ToString();
                        request.Origin = reader[29].ToString();
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }

        /// <summary>
        /// 获取上一篇，下一篇
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public List<NewsKeys> NewsCon(int ID)
        {
            List<NewsKeys> request = new List<NewsKeys>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_News_ConQ]", new object[] { ID }))
                {

                    while (reader.Read())
                    {
                        NewsKeys entity = new NewsKeys();
                        //1-上一篇,2-下一篇
                        entity.Remark = reader[0].ToString();
                        //新闻ID
                        if (reader[1] != DBNull.Value)
                            entity.ID = reader[1].ToInt32();
                        else
                            entity.ID = 0;      
                        //标题
                        entity.Name = reader[2].ToString();                      
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }


        #endregion

        #region 标签
       /// <summary>
        /// 标签列表
       /// </summary>
       /// <param name="PageSize"></param>
       /// <param name="PageIndex"></param>
       /// <param name="ID"></param>
       /// <param name="Name"></param>
       /// <param name="IsDel"></param>
       /// <returns></returns>
        public List<NewsKeys> NewsLabel(int PageSize, int PageIndex, int ID, string Name, bool IsDel)
        {
            List<NewsKeys> request = new List<NewsKeys>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("sp_N_NewsKeys", new object[] { PageSize, (PageIndex - 1) * PageSize, ID, Name, IsDel }))
                {

                    while (reader.Read())
                    {
                        NewsKeys entity = new NewsKeys();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        if (reader[2] != DBNull.Value)
                            entity.IsDel = reader[2].ToBoolean();
                        else
                            entity.IsDel = false;
                        if (reader[3] != DBNull.Value)
                            entity.CreateTime = reader[3].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[4] != DBNull.Value)
                            entity.Updatetime = reader[4].ToDateTime();
                        else
                            entity.Updatetime = DateTime.Now;
                        entity.Remark = reader[5].ToString();
                        if (reader[6] != DBNull.Value)
                            entity.IsNews = reader[6].ToInt32();
                        else
                            entity.IsNews = 0;
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }

       /// <summary>
       /// 标签总数
       /// </summary>
       /// <param name="ID"></param>
       /// <param name="Name"></param>
       /// <param name="IsDel"></param>
       /// <returns></returns>
        public int NewsLabelCount(int ID, string Name, bool IsDel)
        {
            try
            {
                object[] whereInfo = new object[] { ID, Name, IsDel };
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_NewsKeys_C]", whereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return 0;
            }
            catch (Exception ex)
            {
                return -1;
            }

        }

        /// <summary>
        /// 根据ID获取标签
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public NewsKeys NewsLabelByID(int ID)
        {
            NewsKeys entity = new NewsKeys();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_NewsKeys_byId]", new object[] { ID }))
                {
                    while (reader.Read())
                    {
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        if (reader[2] != DBNull.Value)
                            entity.IsDel = reader[2].ToBoolean();
                        else
                            entity.IsDel = false;
                        if (reader[3] != DBNull.Value)
                            entity.CreateTime = reader[3].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[4] != DBNull.Value)
                            entity.Updatetime = reader[4].ToDateTime();
                        else
                            entity.Updatetime = DateTime.Now;
                        entity.Remark = reader[5].ToString();
                        if (reader[6] != DBNull.Value)
                            entity.IsNews = reader[6].ToInt32();
                        else
                            entity.IsNews = 0;
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return entity;
        }


        /// <summary>
        /// 添加或者修改标签
        /// </summary>
        /// <param name="N"></param>
        /// <returns></returns>
        public int NewsLabelSet(NewsKeys N)
        {
            try
            {
                object[] whereInfo = new object[] {N.ID,N.Name,N.Remark };
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_NewsKeys_Set]", whereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return 0;
            }
            catch (Exception ex)
            {
                return -1;
            }

        }

        /// <summary>
        /// 删除标签
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="Del">真删，还是假删</param>
        /// <returns></returns>
        public int NewsLabelDel(int ID, bool Del)
        {
            try
            {
                object[] whereInfo = new object[] { ID, Del };
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_NewsKeys_Del]", whereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return 0;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }



        /// <summary>
        /// 新闻关联标签
        /// </summary>
        /// <param name="N"></param>
        /// <returns></returns>
        public int NewsConKeySet(NewsConKeys N)
        {
            try
            {
                object[] whereInfo = new object[] { N.ID, N.NewsID, N.Label, N.IsDel };
                SQLHelper sqlHelp = new SQLHelper();
                             

                object obj = sqlHelp.ExecuteSPScalar("[sp_N_NewsConKeys_Set]", whereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return 0;
            }
            catch (Exception ex)
            {
                return -1;
            }

        }

        /// <summary>
        /// 删除新闻与标签的关联
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="NewsID"></param>
        /// <param name="LabelID"></param>
        /// <returns></returns>
        public int NewsConKeyDel(int ID, int NewsID, int LabelID,bool IsDelete)
        {
            try
            {
                object[] whereInfo = new object[] { ID, NewsID, LabelID, IsDelete };
                SQLHelper sqlHelp = new SQLHelper();


                object obj = sqlHelp.ExecuteSPScalar("[sp_N_NewsConKeys_Del]", whereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return 0;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }
        #endregion

        #region 解读
        /// <summary>
        /// 后台获取新闻
        /// </summary>
        /// <param name="CateID"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="Title"></param>
        /// <param name="BourseName"></param>
        /// <param name="IsStick"></param>
        /// <param name="IsHeadline"></param>
        /// <param name="HasImg"></param>
        /// <param name="Order">默认为创建时间，1-标题，2-点击率3-交易所，4-回复数</param>
        /// <param name="Desc"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public List<News> ReadingList(int CateID, int PageSize, int PageIndex, string Title, string BourseName, int IsStick, int IsHeadline, bool HasImg, int Order, bool Desc, int IsDel,int UserID)
        {
            List<News> request = new List<News>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { CateID, PageSize, (PageIndex - 1) * PageSize, Title, BourseName, IsStick, IsHeadline, HasImg, Order, Desc, IsDel, UserID };
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_U_News_Q]", obj))
                {

                    while (reader.Read())
                    {
                        News entity = new News();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.CateID = reader[1].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Title = reader[2].ToString();
                        entity.SmallTitle = reader[3].ToString();

                        if (reader[4] != DBNull.Value)
                            entity.Hits = reader[4].ToInt32();
                        else
                            entity.Hits = 0;
                        entity.Shortened = reader[5].ToString();
                        entity.Name = reader[6].ToString();
                        if (reader[7] != DBNull.Value)
                            entity.CreateTime = reader[7].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;

                        entity.Img = reader[8].ToString();
                        if (reader[9] != DBNull.Value)
                            entity.Retotal = reader[9].ToInt32();
                        else
                            entity.Retotal = 0;
                        if (reader[10] != DBNull.Value)
                            entity.Commend = reader[10].ToBoolean();
                        else
                            entity.Commend = false;
                        if (reader[11] != DBNull.Value)
                            entity.Stick = reader[11].ToBoolean();
                        else
                            entity.Stick = false;
                        if (reader[12] != DBNull.Value)
                            entity.IsHeadline = reader[12].ToBoolean();
                        else
                            entity.IsHeadline = false;
                        if (reader[13] != DBNull.Value)
                            entity.IsPush = reader[13].ToBoolean();
                        else
                            entity.IsPush = false;
                        entity.CateName = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            entity.UserID = reader[15].ToInt32();
                        else
                            entity.UserID = 0;
                        if (reader[16] != DBNull.Value)
                            entity.IsDel = reader[16].ToBoolean();
                        else
                            entity.IsDel = true;
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }



        /// <summary>
        /// 手机查询解读
        /// </summary>
        /// <param name="CateID"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="Title"></param>
        /// <param name="BourseName"></param>
        /// <param name="IsStick"></param>
        /// <param name="IsHeadline"></param>
        /// <param name="HasImg"></param>
        /// <param name="Order">默认为创建时间，1-标题，2-点击率3-交易所，4-回复数</param>
        /// <param name="Desc"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public List<News> PReadingList(int CateID, int PageSize, string OpenTime, string EndTime, string Title, string BourseName, int IsStick, int IsHeadline, bool HasImg, int Order, bool Desc, int IsDel, int UserID)
        {
            List<News> request = new List<News>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { CateID, PageSize, OpenTime, EndTime, Title, BourseName, IsStick, IsHeadline, HasImg, Order, Desc, IsDel, UserID };
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_U_News_PQ]", obj))
                {

                    while (reader.Read())
                    {
                        News entity = new News();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.CateID = reader[1].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Title = reader[2].ToString();
                        entity.SmallTitle = reader[3].ToString();

                        if (reader[4] != DBNull.Value)
                            entity.Hits = reader[4].ToInt32();
                        else
                            entity.Hits = 0;
                        entity.Shortened = reader[5].ToString();
                        entity.Name = reader[6].ToString();
                        if (reader[7] != DBNull.Value)
                            entity.CreateTime = reader[7].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;

                        entity.Img = reader[8].ToString();
                        if (reader[9] != DBNull.Value)
                            entity.Retotal = reader[9].ToInt32();
                        else
                            entity.Retotal = 0;
                        if (reader[10] != DBNull.Value)
                            entity.Commend = reader[10].ToBoolean();
                        else
                            entity.Commend = false;
                        if (reader[11] != DBNull.Value)
                            entity.Stick = reader[11].ToBoolean();
                        else
                            entity.Stick = false;
                        if (reader[12] != DBNull.Value)
                            entity.IsHeadline = reader[12].ToBoolean();
                        else
                            entity.IsHeadline = false;
                        if (reader[13] != DBNull.Value)
                            entity.IsPush = reader[13].ToBoolean();
                        else
                            entity.IsPush = false;
                        entity.CateName = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            entity.UserID = reader[15].ToInt32();
                        else
                            entity.UserID = 0;
                        if (reader[16] != DBNull.Value)
                            entity.IsDel = reader[16].ToBoolean();
                        else
                            entity.IsDel = true;
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }


       /// <summary>
       /// 总数
       /// </summary>
       /// <param name="CateID"></param>
       /// <param name="Title"></param>
       /// <param name="BourseName"></param>
       /// <param name="IsStick"></param>
       /// <param name="IsHeadline"></param>
       /// <param name="HasImg"></param>
       /// <param name="IsDel"></param>
       /// <param name="UserID"></param>
       /// <returns></returns>
        public int ReadingCount(int CateID, string Title, string BourseName, int IsStick, int IsHeadline, bool HasImg,int IsDel, int UserID)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] whereinfo = new object[] { CateID, Title, BourseName, IsStick, IsHeadline, HasImg, IsDel, UserID };
                object obj = sqlHelp.ExecuteSPScalar("[sp_U_News_C]", whereinfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return 0;
            }
            catch (Exception ex)
            {
                return 0;
            }
        }


        /// <summary>
        /// 经济商发表解读
        /// </summary>
        /// <param name="N"></param>
        /// <returns></returns>
        public bool ReadingSet(News N)
        {

            try
            {
                object[] whereInfo = new object[] { N.ID, N.CateID, N.Title, N.SmallTitle, N.Text, N.Shortened, N.Name, N.Img, N.Style, N.Hits, N.UserID, N.Origin };
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_U_News_Set]", whereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj) > 0 ? true : false;
                }
                else
                    return false;
            }
            catch (Exception ex)
            {
                return false;
            }

        }



        /// <summary>
        /// 解读删除
        /// </summary>
        /// <param name="U"></param>
        /// <returns></returns>
        public int ReadingDel(int ID, int UserID)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_U_Reading_Del]", new object[] { ID, UserID });
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }


        /// <summary>
        /// 解读删除
        /// </summary>
        /// <param name="U"></param>
        /// <returns></returns>
        public int DelReading(int ID, string Admin)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_U_Reading_DelT]", new object[] { ID, Admin });
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }
        #endregion

        #region 首页/咨询幻灯片
        /// <summary>
        /// 幻灯片
        /// </summary>
        /// <returns></returns>
        public static List<Slide> getImg(int IsOpen, int AppOrWeb)
        {
            List<Slide> entitys = new List<Slide>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Img_Q]", new object[] { IsOpen, AppOrWeb }))
                {
                    Slide entity = null;
                    while (reader.Read())
                    {
                        entity = new Slide();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Title = reader[1].ToString();
                        entity.Text = reader[2].ToString();
                        entity.Name = reader[3].ToString();
                        entity.Url = reader[4].ToString();
                        entity.Img = reader[5].ToString();
                        entity.CreateTime = reader[6].ToDateTime();
                        if (reader[7] != DBNull.Value)
                            entity.IsOpen = reader[7].ToBoolean();
                        else
                            entity.IsOpen = false;
                        if (reader[8] != DBNull.Value)
                            entity.AppOrWeb = reader[8].ToInt32();
                        else
                            entity.AppOrWeb = 0;

                        entitys.Add(entity);
                    }

                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }

            return entitys;
        }


        /// <summary>
        /// 后台查询所有幻灯片
        /// </summary>
        /// <returns></returns>
        public static List<Slide> getMImg(int IsOpen, int AppOrWeb,int Order,bool Desc)
        {
            List<Slide> entitys = new List<Slide>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Img_MQ]", new object[] { IsOpen, AppOrWeb ,Order, Desc}))
                {
                    Slide entity = null;
                    while (reader.Read())
                    {
                        entity = new Slide();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Title = reader[1].ToString();
                        entity.Text = reader[2].ToString();
                        entity.Name = reader[3].ToString();
                        entity.Url = reader[4].ToString();
                        entity.Img = reader[5].ToString();
                        entity.CreateTime = reader[6].ToDateTime();
                        if (reader[7] != DBNull.Value)
                            entity.IsOpen = reader[7].ToBoolean();
                        else
                            entity.IsOpen = false;
                        if (reader[8] != DBNull.Value)
                            entity.AppOrWeb = reader[8].ToInt32();
                        else
                            entity.AppOrWeb = 0;

                        entitys.Add(entity);
                    }

                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }

            return entitys;
        }

        /// <summary>
        /// 删除幻灯片
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static int DelImg(int ID)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Img_D]", ID);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        /// <summary>
        /// 新增或者修改幻灯片
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int AddOrUpImg(Slide model)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] WhereInfo = new object[] { model.ID, model.Title, model.Text, model.Name, model.Url, model.Img, model.IsOpen, model.AppOrWeb };
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Img_Set]", WhereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
                //throw ex;
            }
        }

        /// <summary>
        /// 根据ID获取幻灯片
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static Slide ImgByID(int ID)
        {
            Slide entity = new Slide();
            try
            {

                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Img_ByID]",ID))
                {
                    while (reader.Read())
                    {

                        entity = new Slide();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Title = reader[1].ToString();
                        entity.Text = reader[2].ToString();
                        entity.Name = reader[3].ToString();
                        entity.Url = reader[4].ToString();
                        entity.Img = reader[5].ToString();
                        entity.CreateTime = reader[6].ToDateTime();
                        if (reader[7] != DBNull.Value)
                            entity.IsOpen = reader[7].ToBoolean();
                        else
                            entity.IsOpen = false;
                        if (reader[8] != DBNull.Value)
                            entity.AppOrWeb = reader[8].ToInt32();
                        else
                            entity.AppOrWeb = 0;
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entity;
        }
        #endregion

        #region 手机资讯
        /// <summary>
        /// 后台获取新闻
        /// </summary>
        /// <param name="CateID"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="Title"></param>
        /// <param name="BourseName"></param>
        /// <param name="IsStick"></param>
        /// <param name="IsHeadline"></param>
        /// <param name="HasImg"></param>
        /// <param name="Order">默认为创建时间，1-标题，2-点击率3-交易所，4-回复数</param>
        /// <param name="Desc"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public List<News> PNewsList(string OpenTime, string EndTime, int PageSize, int CateID, string Title, string Name, int IsStick, int IsHeadline, bool HasImg, int Order, bool Desc, int IsDel)
        {
            List<News> request = new List<News>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { OpenTime, EndTime, PageSize, CateID, Title, Name, IsStick, IsHeadline, HasImg, Order, Desc, IsDel };
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_News_PQ]", obj))
                {

                    while (reader.Read())
                    {
                        News entity = new News();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.CateID = reader[1].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Title = reader[2].ToString();
                        entity.SmallTitle = reader[3].ToString();

                        if (reader[4] != DBNull.Value)
                            entity.Hits = reader[4].ToInt32();
                        else
                            entity.Hits = 0;
                        entity.Shortened = reader[5].ToString();
                        entity.Name = reader[6].ToString();
                        if (reader[7] != DBNull.Value)
                            entity.CreateTime = reader[7].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;

                        entity.Img = reader[8].ToString();
                        if (reader[9] != DBNull.Value)
                            entity.Retotal = reader[9].ToInt32();
                        else
                            entity.Retotal = 0;
                        if (reader[10] != DBNull.Value)
                            entity.Commend = reader[10].ToBoolean();
                        else
                            entity.Commend = false;
                        if (reader[11] != DBNull.Value)
                            entity.Stick = reader[11].ToBoolean();
                        else
                            entity.Stick = false;
                        if (reader[12] != DBNull.Value)
                            entity.IsHeadline = reader[12].ToBoolean();
                        else
                            entity.IsHeadline = false;
                        if (reader[13] != DBNull.Value)
                            entity.IsPush = reader[13].ToBoolean();
                        else
                            entity.IsPush = false;
                        entity.CateName = reader[14].ToString();
                        request.Add(entity);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return request;
        }
        #endregion
    }
}
